package org.fordprefect.struts2jscalendarplugin.views.jsp.ui;

import com.opensymphony.xwork2.util.ValueStack;
import org.apache.log4j.Logger;
import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ui.AbstractUITag;
import org.fordprefect.struts2jscalendarplugin.components.JSCalendar;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @see org.fordprefect.struts2jscalendarplugin.components.JSCalendar
 */
public class JSCalendarTag extends AbstractUITag {

    protected String language;
    protected String format;
    protected String showstime;
    protected String singleclick;
    protected String flat;
    protected String flatCallback;
    private static Logger log = Logger.getLogger(JSCalendarTag.class);
    
    public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
        return new JSCalendar(stack, req, res);
    }

    protected void populateParams() {
        super.populateParams();        
        final JSCalendar JSCalendar = (JSCalendar) component;
        JSCalendar.setLanguage(language);
        JSCalendar.setFormat(format);
        JSCalendar.setShowstime(showstime);
        JSCalendar.setSingleclick(singleclick);
        JSCalendar.setFlat(flat);
        JSCalendar.setFlatCallback(flatCallback);
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public void setFormat(String format) {
        this.format = format;
    }

    public void setShowstime(String showstime) {
        this.showstime = showstime;
    }

    public void setSingleclick(String singleclick) {
        this.singleclick = singleclick;
    }

    public void setFlat(String flat) {
        this.flat = flat;
    }

    public void setFlatCallback(String flatCallback) {
        this.flatCallback = flatCallback;
    }
}
